home *** CD-ROM | disk | FTP | other *** search
- head 2.1;
- branch ;
- access ;
- symbols no-auto-remigrate:2.1 installed:2.0;
- locks ; strict;
- comment @ * @;
-
-
- 2.1
- date 90.06.22.14.58.21; author douglis; state Exp;
- branches ;
- next 2.0;
-
- 2.0
- date 90.03.10.13.12.45; author douglis; state Stable;
- branches ;
- next 1.3;
-
- 1.3
- date 90.03.10.13.10.55; author douglis; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 90.02.28.10.57.54; author douglis; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 90.02.16.14.28.47; author douglis; state Exp;
- branches ;
- next ;
-
-
- desc
- @Get info about one or more hosts from the global daemon.
- @
-
-
- 2.1
- log
- @changes for alarms for timeouts with migd and for printing to stderr instead of syslog
- @
- text
- @/*
- * Mig_GetAllInfo.c --
- *
- * Get info about one or more hosts from the global daemon.
- *
- * Copyright 1990 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/Mig_GetAllInfo.c,v 2.0 90/03/10 13:12:45 douglis Stable Locker: douglis $ SPRITE (Berkeley)";
- #endif not lint
-
-
- #include <sprite.h>
- #include <stdio.h>
- #include <mig.h>
- #include <kernel/net.h>
- #include <errno.h>
-
- extern int errno;
- extern char *strerror();
- extern char *malloc();
-
- /*
- * The maximum number of records we transfer in a single ioctl.
- */
- #define MAX_RECS 20
-
- /*
- *----------------------------------------------------------------------
- *
- * Mig_GetAllInfo --
- *
- * Get the records for all hosts, up to the number of hosts specified.
- *
- * Results:
- * The number of valid records found is returned, and the data are
- * placed in *infoPtr. Upon error, -1 is returned.
- *
- * Side effects:
- * The global daemon is contacted if it has not been already.
- *
- *----------------------------------------------------------------------
- */
- int
- Mig_GetAllInfo(infoPtr, numRecs)
- Mig_Info *infoPtr; /* Pointer to array of structures */
- int numRecs; /* number of structures in *infoPtr */
- {
- Mig_InfoRequest request;
- static int init = 0; /* Initialized? */
- static char *buffer; /* Dynamically-allocated buffer for result
- of ioctl. */
- static unsigned int bufSize;/* Size of buffer. */
- int status; /* Status of system calls. */
- int maxRecs = MAX_RECS; /* Maximum number of recs in one ioctl. */
- int obtained; /* Number obtained thus far. */
- int got; /* Number obtained in one iteration. */
- int nextHost; /* Next entry to look for. */
- int retry = 1; /* Whether to retry after failed ioctl. */
-
-
- if (mig_GlobalPdev < 0) {
- if (MigOpenPdev(TRUE) < 0) {
- return(-1);
- }
- }
-
- if (!init) {
- init = 1;
- bufSize = 2 * sizeof(int) + maxRecs * sizeof(Mig_Info);
- buffer = malloc(bufSize);
- if (buffer == (char *) NULL) {
- errno = ENOMEM;
- init = 0;
- return(-1);
- }
- }
- nextHost = 1;
-
- for (obtained = 0; obtained < numRecs;) {
- request.numRecs = maxRecs;
- request.firstHost = nextHost;
-
- if (MigSetAlarm() < 0) {
- fprintf(stderr,
- "Error setting alarm for contact with migd.\n");
- return(-1);
- }
- status = Fs_IOControl(mig_GlobalPdev, IOC_MIG_GETINFO,
- sizeof(Mig_InfoRequest),
- (char *) &request,
- bufSize, buffer);
- if (MigClearAlarm() < 0) {
- fprintf(stderr,
- "Error clearing alarm for contact with migd.\n");
- }
- if (status != SUCCESS) {
- close(mig_GlobalPdev);
- mig_GlobalPdev = 0;
- if (retry == 0 || MigOpenPdev(TRUE) < 0) {
- fprintf(stderr,
- "Mig_GetAllInfo: error during ioctl to global master: %s\n",
- Stat_GetMsg(status));
- errno = Compat_MapCode(status);
- return(-1);
- }
- retry = 0;
- continue;
- }
- retry = 1;
- got = *((int *) buffer);
- if (got == 0) {
- break;
- }
- obtained += got;
- bcopy(buffer + 2 * sizeof(int), (char *) infoPtr,
- got * sizeof(Mig_Info));
- if (got < maxRecs) {
- break;
- }
- nextHost = infoPtr[got-1].hostID + 1;
- infoPtr += got;
- }
-
- return(obtained);
-
- }
- @
-
-
- 2.0
- log
- @Changing version numbers.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/Mig_GetAllInfo.c,v 1.3 90/03/10 13:10:55 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- d22 1
- a23 1
- #include <syslog.h>
- d92 5
- d101 4
- d109 1
- a109 1
- syslog(LOG_WARNING,
- @
-
-
- 1.3
- log
- @changed when it prints syslog message
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/Mig_GetAllInfo.c,v 1.2 90/02/28 10:57:54 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- @
-
-
- 1.2
- log
- @changed Mig_OpenPdev to internal Mig routine.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/Mig_GetAllInfo.c,v 1.1 90/02/16 14:28:47 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- a96 3
- syslog(LOG_WARNING,
- "Mig_GetAllInfo: error during ioctl to global master: %s\n",
- Stat_GetMsg(status));
- d100 3
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d4 1
- a4 1
- * Source code for the Mig_GetAllInfo procedure.
- d17 1
- a17 1
- static char rcsid[] = "$Header: /user2/douglis/pdev_mig/mig_p/RCS/Mig_GetAllInfo.c,v 1.3 90/02/13 10:07:13 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- d71 1
- a71 1
- if (Mig_OpenPdev(TRUE) < 0) {
- d102 1
- a102 1
- if (retry == 0 || Mig_OpenPdev(TRUE) < 0) {
- @
-